package com.bishe.dao;

import com.bishe.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 用户数据层
 * @date 2022/03/03 47:03:07
 */
public interface UserDao {

    @Select("select * from user")
    List<User> findAll();


    @Select("select * from user where userName = #{userName} and passWord = #{password} ")
    User checkUser(@Param("userName") String userName, @Param("password") String password);


    @Select("select * from user where id = #{id}")
    User findById(@Param("id") String id);

    @Delete("delete  from user where id = #{id}")
    void deleteById(@Param("id") String id);


    @Update("update user set " +
            "id = #{id}," +
            "userName = #{userName}," +
            "nikName = #{nikName}," +
            "passWord = #{passWord}," +
            "age = #{age}," +
            "phone = #{phone}," +
            "sex = #{sex}," +
            "post = #{post}," +
            "money = #{money}," +
            "createTime = #{createTime}" +
            " where id = #{id}")
    void updateById(User user);


    @Insert("insert into user(id,post,money,userName,phone,nikName,passWord,age,sex,createTime) " +
            "values(#{id}" +
            ",#{post}" +
            ",#{money}" +
            ",#{userName}" +
            ",#{phone}" +
            ",#{nikName}" +
            ",#{passWord}" +
            ",#{age}" +
            ",#{sex}" +
            ",#{createTime})")
    void save(User user);
}
